<%@Page Language="VB"%>
<html>
<head>

<script language="JScript">
<!--
function ShowHTMLContent() {
  var strURL = 'http://<% = Request.ServerVariables("SERVER_NAME") %><% = Request.Path %>?<% = Request.QueryString %>';
  var strDisplay = new String;
  var objHTTP = new ActiveXObject("microsoft.XMLHTTP")
  objHTTP.open('GET', strURL, false);
  objHTTP.send();
  var strReply = objHTTP.responseText;
  var intStart = strReply.indexOf('<!' + '--start-->') + 12;
  var intEnd = strReply.indexOf('<!' + '--end-->');
  if ((intStart > 0) && (intEnd > intStart))
    var strDisplay = strReply.substring(intStart, intEnd);
  document.all['outHTML'].innerText = strDisplay + ' ';
}
function SetCheck(strCheckboxName) {
  document.all[strCheckboxName].checked = true;
}
//-->
</script>

<!-- #include file="style.inc" -->
</head>
<body bgcolor="#ffffff" onload="ShowHTMLContent()">
<!--------------------------------------------------------------------------->
<span class="heading">HtmlTable Control</span><p />

<!--start-->
<table id="MyControl" runat="server" />
<!--end-->

<p /><div id="outError" runat="server" /><p />
<font face="Courier New" size="2"><div style="background-color:gainsboro; padding-left:10px" id="outHTML">Fetching HTML content...</div></font>

<form runat="server" method="get">
<table border="0">
<tr>
<td align="right" nowrap="nowrap" colspan="2">Number of Rows =</td>
<td nowrap="nowrap"><select id="selRows" size="1" runat="server">
<option>1</option><option>2</option><option>3</option><option>4</option></select></td>
<td nowrap="nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &nbsp;</td>
<td align="right" nowrap="nowrap" colspan="2">Number of Columns =</td>
<td nowrap="nowrap"><select id="selCols" size="1" runat="server">
<option>1</option><option>2</option><option>3</option><option>4</option><option>5</option><option>6</option></select></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkAlign" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Align =</td><td nowrap="nowrap"><select id="selAlign" size="1" runat="server" onchange="SetCheck('chkAlign')">
<option></option><option>AbsBottom</option><option>AbsMiddle</option><option>Baseline</option><option>Bottom</option><option>Left</option>
<option>Middle</option><option>Right</option><option>TextTop</option><option>Top</option></select></td><td nowrap="nowrap"></td>
<td nowrap="nowrap"><input type="checkbox" id="chkBgColor" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">BgColor =</td><td nowrap="nowrap"><input type="text" size="15" id="txtBgColor" runat="server" onkeypress="SetCheck('chkBgColor')" /></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkBorder" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Border =</td><td nowrap="nowrap"><input type="text" size="3" id="txtBorder" runat="server" onkeypress="SetCheck('chkBorder')" />px</td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkBorderColor" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">BorderColor =</td><td nowrap="nowrap"><input type="text" size="15" id="txtBorderColor" runat="server" onkeypress="SetCheck('chkBorderColor')" /></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkCellPadding" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">CellPadding =</td><td nowrap="nowrap"><input type="text" size="3" id="txtCellPadding" runat="server" onkeypress="SetCheck('chkCellPadding')" />px</td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkCellSpacing" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">CellSpacing =</td><td nowrap="nowrap"><input type="text" size="3" id="txtCellSpacing" runat="server" onkeypress="SetCheck('chkCellSpacing')" />px</td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkHeight" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Height =</td><td nowrap="nowrap"><input type="text" size="3" id="txtHeight" runat="server" onkeypress="SetCheck('chkHeight')" />px</td><td></td>
<td nowrap="nowrap"></td><td align="right" nowrap="nowrap">ID =</td><td nowrap="nowrap"><% = MyControl.ID %></td>
</tr><tr>
<td nowrap="nowrap"><input type="checkbox" id="chkVisible" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Visible =</td><td nowrap="nowrap"><select id="selVisible" size="1" runat="server" onchange="SetCheck('chkVisible')"><option>True</option><option>False</option></select></td><td></td>
<td nowrap="nowrap"><input type="checkbox" id="chkWidth" runat="server" /> Set: &nbsp; </td><td align="right" nowrap="nowrap">Width =</td><td nowrap="nowrap"><input type="text" size="3" id="txtWidth" runat="server" onkeypress="SetCheck('chkWidth')" />px</td>
</tr><tr>
<td></td><td></td><td></td><td></td>
<td nowrap="nowrap"><input type="button" Value="Reset" onclick="javascript:location.href='http://<% = Request.ServerVariables("SERVER_NAME") %><% = Request.Path %>'"></td><td nowrap="nowrap"></td><td nowrap="nowrap"><input type="submit" Value="Update" runat="server" /></td>
</tr>
</table>
</form>

<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
   outError.innerHTML = ""
   Try
     'create the table
      Dim intRows As Integer = selRows.Value
      Dim intCols As Integer = selCols.Value
      Dim intRowCount, intColCount As Integer
      Dim objRow As HtmlTableRow
      Dim objCell As HtmlTableCell
      For intRowCount = 0 To intRows - 1
        objRow = New HtmlTableRow()
        For intColCount = 0 To intCols - 1
          objCell = New HtmlTableCell()
          objCell.InnerHtml = "R" & intRowCount & "C" & intColCount
          objRow.Cells.Add(objCell)
        Next
        MyControl.Rows.Add(objRow)
      Next

      If IsPostBack() Then

         If chkAlign.Checked Then 
	MyControl.Align = selAlign.Value
         end if
         If chkBgColor.Checked Then 
	MyControl.BgColor = txtBgColor.Value
         end if
         If chkBorder.Checked Then 
	MyControl.Border = txtBorder.Value
         end if
         If chkBorderColor.Checked Then 
	MyControl.BorderColor = txtBorderColor.Value
         end if
         If chkCellPadding.Checked Then 
	MyControl.CellPadding = txtCellPadding.Value
         end if
         If chkCellSpacing.Checked Then 
	MyControl.CellSpacing = txtCellSpacing.Value
         end if
         If chkHeight.Checked Then 
	MyControl.Height = txtHeight.Value
         end if
         If chkVisible.Checked Then 
	MyControl.Visible = selVisible.Value
         end if
         If chkWidth.Checked Then 
	MyControl.Width = txtWidth.Value
         end if
      End If
      selAlign.Value = MyControl.Align
      txtBgColor.Value = MyControl.BgColor
      txtBorder.Value = MyControl.Border
      txtBorderColor.Value = MyControl.BorderColor
      txtCellPadding.Value = MyControl.CellPadding
      txtCellSpacing.Value = MyControl.CellSpacing
      txtHeight.Value = MyControl.Height
      selVisible.Value = MyControl.Visible
      txtWidth.Value = MyControl.Width

   Catch objError As Exception
      outError.innerHTML = "<b>* Error</b>: " & objError.Message & "<p />"
   End Try
End Sub
</script>

<!--------------------------------------------------------------------------->
<!-- #include file="foot.inc" -->
</body>
</html>
